{% extends "admin/base.html" %}

{% block stylesheets %}
{% endblock %}

{% block content %}
	{% include "challenge-feedback-modal.html" %}

<input type="hidden" value="{{ nonce }}" id="nonce">

{#	Div used to inject update modal #}
<div id="update-modals-entry-div">
</div>

<div class="jumbotron">
	<div class="container">
		<h1>Challenge Feedback</h1>
	</div>
</div>
<div class="container">
	<div class="row">
		<div class="col-md-12">
			<div>
				<table id="challenges" class="table table-striped">
					<thead>
					<tr>
						<td><b>ID</b></td>
						<td><b>Name</b></td>
						<td class="d-none d-md-table-cell d-lg-table-cell"><b>Category</b></td>
						<td class="d-none d-md-table-cell d-lg-table-cell"><b>Value</b></td>
						<td class="d-none d-md-table-cell d-lg-table-cell"><b>Type</b></td>
						<td class="d-none d-md-table-cell d-lg-table-cell text-center"><b>Status</b></td>
						<td style="width: 200px;"><b>Settings</b></td>
					</tr>
					</thead>
					<tbody>
					{% for challenge in challenges %}
						<tr>
							<td>{{ challenge.id }}</td>
							<td>{{ challenge.name }}</td>
							<td class="d-none d-md-table-cell d-lg-table-cell">{{ challenge.category }}</td>
							<td class="d-none d-md-table-cell d-lg-table-cell">{{ challenge.value }}</td>
							<td class="d-none d-md-table-cell d-lg-table-cell">{{ challenge.type }}</td>
							<td class="d-none d-md-table-cell d-lg-table-cell text-center">
								{% if challenge.hidden %}
									<span class="badge badge-danger">hidden</span>
								{% else %}
									<span class="badge badge-success">visible</span>
								{% endif %}
							</td>
							<td>
								<span class="view-feedback" data-toggle="tooltip"
									  data-placement="top" title="View feedbacks"
									  chal-id="{{ challenge.id }}">
									<i class="btn-fa fas fa-file-alt" aria-hidden="true" chal-id="{{ challenge.id }}"></i>
								</span>
							</td>
						</tr>
					{% endfor %}
					</tbody>
				</table>
			</div>
		</div>
		<div class="col-md-12">
			<div class="text-right">
				<a href="{{ request.script_root }}/admin/feedbacks/export" id="export-feedback-button" class="btn btn-warning">Export to JSON</a>
				<a href="{{ request.script_root }}/admin/feedbacks/export_csv" id="export-feedback-button" class="btn btn-warning">Export to CSV</a>
			</div>
		</div>
	</div>
</div>
{% endblock %}

{% block scripts %}
	<script type="text/javascript">
	</script>
	<script src="{{ request.script_root }}/challenge-feedback/static/challenge-feedback-config.js"></script>
	<script src="{{ request.script_root }}/themes/admin/static/js/multi-modal.js"></script>
{% endblock %}
